<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      padding: 0;
      margin: 0;
    }

    .dv {
      width: 300px;
      height: 300px;
      background: yellow;
    }
  </style>
</head>

<body>
  <!-- 
    classList 返回函数的类名列表，属性只读。
      可以通过add()和remove()来修改
   -->
  <input type="button" value="点击吧" id="btn">
  <div>文本</div>
</body>
<script>
  document.querySelector("#btn").addEventListener("click", () => {
    // 让我们当前的类名改为 dv
    document.querySelector("div").className = "dv";
  });
</script>

</html>